﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

#pragma warning disable 1998
namespace Elderos.Ontology
{
    public class FakeOntologyData : IOntologyData
    {
        private List<Attribute> _attributes = new List<Attribute>();

        public List<Attribute> Attributes
        {
            get { return _attributes; }
            private set { _attributes = value; }
        }

        private List<FreebaseType> _types = new List<FreebaseType>();

        public List<FreebaseType> Types
        {
            get { return _types; }
            private set { _types = value; }
        }

        private HashSet<string> _commonWords = new HashSet<string>();

        public HashSet<string> CommonWords
        {
            get { return _commonWords; }
            private set { _commonWords = value; }
        }

        public HashSet<string> PreNames
        {
            get { return _preNames; }
            private set { _preNames = value; }
        }

        private HashSet<string> _names = new HashSet<string>();

        public HashSet<string> Names
        {
            get { return _names; }
            private set { _names = value; }
        }

        private Dictionary<string, int> _trigrams = new Dictionary<string, int>();

        public Dictionary<string, int> Trigrams
        {
            get { return _trigrams; }
            private set { _trigrams = value; }
        }

        private Dictionary<string, DictionaryWord> _wordsDictionary = new Dictionary<string, DictionaryWord>();
        private HashSet<string> _preNames = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase)
                                                {
                                                    "van",
                                                    "von",
                                                    "de",
                                                    "d",
                                                    "di",
                                                    "del",
                                                    "da",
                                                    "'",
                                                    "`",
                                                    "der",
                                                    "ibn",
                                                    "O",
                                                    "l",
                                                    "le",
                                                    "la",
                                                    "les",
                                                    "of",
                                                    "the"
                                                };

        public Dictionary<string, DictionaryWord> WordsDictionary
        {
            get { return _wordsDictionary; }
            private set { _wordsDictionary = value; }
        }

        public bool Initialized { get { return true; } }

        private Entity FakeEntity { get { return new Entity() {EntityID = -1, MID = "/m/null", Name = "null"}; } }


        public async Task<Entity> GetEntityAsync(int entityID)

        {
            return FakeEntity;
        }

        public async Task<List<AttValue>> GetAttValuesAsync(IEnumerable<int> attributeIDs, IEnumerable<int> entityIDs)
        {
            return new List<AttValue>();
        }

        public async Task<List<AttRef>> GetAttRefsAsync(IEnumerable<int> attributeIDs, IEnumerable<int> entityIDs)
        {
            return new List<AttRef>();
        }

        public async Task<List<AttRef>> GetAttRefsAsync(IEnumerable<int> attributeIDs)
        {
            return new List<AttRef>();
        }

        public async Task<List<EntityFBType>> GetEntityFBTypesAsync(IEnumerable<int> entityIDs)
        {
            return new List<EntityFBType>();
        }

        public async Task<List<Synonym>> GetSynonymsAsync(IEnumerable<int> synonymIDs)
        {
            return new List<Synonym>();
        }

        public Network GetNetwork(int networkID)
        {
            return null;
        }

        public int InsertNetwork(Network network)
        {
            return -1;
        }

        public void UpdateNetwork(Network network)
        {
        }

        public void DeleteNetwork(int networkID)
        {
        }

        public async Task<Dictionary<string, double>> GetSynonymFrequenciesAsync(IEnumerable<string> synonyms)
        {
            return new Dictionary<string, double>();
        }

        public void Initialize()
        {
        }

        public IEnumerable<SynonymEntityDTO> GetFBTypeSynonyms(IEnumerable<string> fbtypes)
        {
            yield return new SynonymEntityDTO(){EntityID = -1, Synonym = "Name Lastname", SynonymID = -4};
        }

        public IEnumerable<NameSynonym> GetNameSynonyms()
        {
            yield return new NameSynonym() {Name = "Bill", Normalized = "William"};
        }

        public IEnumerable<SynonymEntityDTO> LoadSynonyms()
        {
            yield return new SynonymEntityDTO {EntityID = -1, Synonym = "The Argentine", SynonymID = -1};
            yield return new SynonymEntityDTO { EntityID = -2, Synonym = "Argentine", SynonymID = -2 };
            yield return new SynonymEntityDTO { EntityID = -3, Synonym = "Argentine", SynonymID = -2 };
            yield return new SynonymEntityDTO { EntityID = -2, Synonym = "Argentine adventure", SynonymID = -3 };
        }

        public int EstimatedSynonymCount { get { return 2; } }
    }
}
#pragma warning restore 1998